package com.FBinggun.Ls;


import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.inventory.InventoryCloseEvent;
import org.bukkit.scheduler.BukkitRunnable;

import com.FBinggun.CH;


public class Gui implements Listener{

	
	
	@EventHandler
	public void clickgui(InventoryCloseEvent e) throws Exception {
		com.FBinggun.Chenghao.Gui g = new com.FBinggun.Chenghao.Gui();

		g.clickgui(e);
		g.cldelete(e);

	}
	
	@EventHandler
	public void clickgui(InventoryClickEvent e) throws NumberFormatException, Exception {
		com.FBinggun.Chenghao.Gui g = new com.FBinggun.Chenghao.Gui();

		g.setuse(e);
		g.delete(e);
		
		if(com.FBinggun.Chenghao.Gui.gui.get(e.getWhoClicked().getName())!=null) {
		new BukkitRunnable() {
			@Override
			public void run() {
				e.getWhoClicked().closeInventory();
				
			}
		}
		.runTask(CH.getPlugin(CH.class));
	}
		if(com.FBinggun.Chenghao.Gui.delete.get(e.getWhoClicked().getName())!=null) {
		new BukkitRunnable() {
			@Override
			public void run() {
				e.getWhoClicked().closeInventory();
				
			}
		}
		.runTask(CH.getPlugin(CH.class));
	}
		
	}
	
	
}
